package com.neural.neighbourhood;

import static java.lang.Math.pow;
import static java.lang.Math.round;

import java.util.ArrayList;
import java.util.List;

import com.neural.descriptor.Point;
import com.neural.descriptor.SizeDescriptor;

public class SquareNeighbourhood extends Neighbourhood {

	public SquareNeighbourhood() {
		super("square");
	}

	@Override
	public List<Point> getPointsFor(Point point, SizeDescriptor size, Integer neighbourSize) {

		List<Point> points = new ArrayList<Point>((int) round(pow(neighbourSize * 2 + 1, 2.0)));
		for (int i = -neighbourSize; i <= neighbourSize; i++) {
			for (int j = -neighbourSize; j <= neighbourSize; j++) {
				addIfCan(points, point, size, i, j);
			}
		}
		points.remove(point);

		return points;
	}
}
